package com.burger.service.impl;

import com.burger.dao.LoginDao;
import com.burger.domain.User;
import com.burger.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private LoginDao loginDao;

    @Override
    public boolean login(User user) {
        if (loginDao.login(user)!=null){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean register(User user) {
        if (loginDao.findByName(user.getName())!=null){
            return false;
        }else {
            loginDao.register(user);
            return true;
        }
    }

    @Override
    public List<User> findAll() {
        return loginDao.findAll();
    }

    @Override
    public User findByName(String name) {
        return loginDao.findByName(name);
    }


}
